<?php

namespace  bc\model;

use bc\ar\MActiveRecord;

class ItemdetailModel extends \bc\ar\MActiveRecord{
    /**
     * bc_item_detail表
     */
    public static function tableName()
   {
		return '{{%item_detail}}'; 
   }
   
   public function tractionInsert($item_data_id,$values,$newsubitemkey)
    {
    	//$transaction = $this->getDb()->beginTransaction();
 
    	try 
    	{
	    	foreach ($values as $key=>$value)
	    	{       
                     if($value != $newsubitemkey){
	    		$sql = 'INSERT ' . self::getTableSchema ()->name . "(item_data_id, subitem_id, subitem_value , deleted) VALUES ( {$item_data_id}, '{$value}',1,0)";
	    		$this->getDb()->createCommand($sql)->execute();
                        //echo $sql;
                     }
	    	}
    		
    		//$transaction->commit();
    	}
		catch (\Exception $e) 
    	{
			//$transaction->rollBack();
			throw $e;
    	}
    }
}
